package com.lancoo.edu.platform.operation.commons.dto;

import com.lancoo.edu.platform.operation.commons.exception.ServiceException;

/**
 * 条件工厂
 *
 * @author pky
 */
public class ConditionFactory {

    private ConditionFactory() {

    }

    /**
     * 单例模式conditionFactory 实例
     */
    private static final class ConditionFactoryHolder {
        static final ConditionFactory CONDITION_FACTORY = new ConditionFactory();
    }

    /**
     * 获取 conditionFactory 实例
     *
     * @return 工程
     */
    public static ConditionFactory getInstance() {
        return ConditionFactoryHolder.CONDITION_FACTORY;
    }

    /**
     * 满足条件则抛异常
     *
     * @param msg 说明
     */
    public void throwServiceException(Boolean condition, String msg) {
        if (condition) {
            throw new ServiceException(msg);
        }
    }

}
